#include "Server.hpp"
#include "Log.hpp"
#include "Service.hpp"
#include "NetCal.hpp"

int main(int argc,char* argv[])
{
    if(argc != 2)
    {
        LOG(ERROR,"./tcpserver serverport\n");
        exit(2);
    }
    uint16_t localport = std::stoi(argv[1]);
    
    NetCal nc;

    IOService service(std::bind(&NetCal::Calculator,&nc,std::placeholders::_1));

    std::unique_ptr<TcpServer> server = std::make_unique<TcpServer>(
        std::bind(&IOService::IOExcute,&service,std::placeholders::_1,std::placeholders::_2),
        localport);
    
    server->Loop();

    return 0;
}